<template>
	<view>
		<uv-upload :fileList="fileList1" name="1" multiple :maxCount="10" @afterRead="afterRead"
			@delete="deletePic"></uv-upload>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '我的',
				top: 0,
				height: 64,
				tops: 120,
				data: {},
				/* ------------------------------ */
				fileList1: [],

			}
		},
		onLoad() {
			this.getInfo();
			let obj = {};
			obj = wx.getMenuButtonBoundingClientRect();
			setTimeout(() => {
				uni.getSystemInfo({
					success: (res) => {
						this.height = obj.top ? (obj.top + obj.height + 8) : (res.statusBarHeight +
							44);
						this.top = obj.top ? (obj.top + (obj.height - 32) / 2) : (res
							.statusBarHeight);
						// #ifdef MP
						this.tops = this.top + this.height + 15
						// #endif
					}
				})
			}, 100)
		},
		methods: {
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'http://192.168.2.21:7001/upload', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							setTimeout(() => {
								resolve(res.data.data)
							}, 1000)
						}
					});
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f7f8fa;
	}

	.user-section {
		position: relative;
		height: 600rpx;
		margin-bottom: -300rpx;

		.bg {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 100%;
			filter: blur(2rpx);
			opacity: .7;
		}
	}


	.cover-container {
		margin: 0 30rpx;
		margin-top: -40rpx;
		position: relative;
		padding-bottom: 20rpx;
		min-height: 160rpx;
		box-sizing: border-box;

		.ul-section {
			border-radius: 16rpx;
			background: #fff;
			margin-bottom: 20rpx;

			.list-cell {
				display: flex;
				-webkit-box-align: baseline;
				-webkit-align-items: baseline;
				-ms-flex-align: baseline;
				align-items: baseline;
				padding: 20rpx 30rpx;
				line-height: 60rpx;
				position: relative;

				.cell-icon {
					align-self: center;
					width: 32rpx;
					max-height: 32rpx;
					font-size: 38rpx;
					margin-right: 20rpx;
				}

				.cell-more {
					align-self: center;
					font-size: 30rpx;
					color: #999999;
					margin-left: 20rpx;
				}

				.cell-tit {
					flex: 1;
					font-size: 28rpx;
					color: #303133;
					margin-right: 10rpx;
				}
			}
		}
	}

	.tui-header-center {
		position: absolute;
		width: 100%;
		height: 128rpx;
		left: 0;
		top: 120rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}

	.tui-avatar {
		flex-shrink: 0;
		width: 128rpx;
		height: 128rpx;
		display: block;
		border-radius: 50%;
		border: 4rpx solid #fff;
		box-sizing: border-box;
	}

	.tui-info {
		width: 70%;
		padding-left: 30rpx;

	}

	.tui-nickname {
		font-size: 30rpx;
		font-weight: 500;
		color: #333;
		display: flex;
		align-items: center;
	}

	.tui-img-move {
		// width: 12rpx;
		// height: 22rpx;
		margin-left: 12rpx;
		font-size: 24rpx;
		font-weight: bold;
	}

	.tui-explain {
		width: 80%;
		font-size: 24rpx;
		font-weight: 400;
		color: #333;
		padding-top: 8rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}



	.order-section {
		position: absolute;
		left: 30rpx;
		right: 30rpx;
		top: 300rpx;
		padding: 28rpx 0;
		display: flex;
		justify-content: space-around;
		align-content: center;
		background: #fff;
		border-radius: 10rpx;

		.order-item {
			font-size: 28rpx;
			color: #333;
		}

		.order-text {
			font-size: 24rpx;
			color: #333333;
		}

		.yticon {
			width: 95rpx;
			height: 95rpx;
			font-size: 48rpx;
			margin: 0 auto;
			margin-bottom: 18rpx;
			display: block;
			// border: 2rpx solid #ebebeb;
			// border-radius: 50%;
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;

			image {
				// width: 40rpx;
				// max-height: 40rpx;
				width: 100%;
				height: 100%;
			}

			.number {
				font-size: 24rpx;
				background: #ff7f66;
				height: 28rpx;
				line-height: 28rpx;
				padding: 0 10rpx;
				border-radius: 14rpx;
				position: absolute;
				top: 0;
				right: 0;
				color: #fff;
			}
		}

	}
</style>